<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="UTF-8">
  <meta name="author" content="wangbo">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    .box {
      width: 200px;
      height: 200px;
      background-color: hotpink;
    }
  </style>
</head>

<body>
  <table>
    <thead>
        <tr>
            <th>名字</th>
            <th>性别</th>
            <th>年龄</th>
            <th>身高</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td>张三</td>
            <td>男</td>
            <td>21</td>
            <td>185cm</td>
        </tr>
        <tr>
            <td>张三</td>
            <td>男</td>
            <td>21</td>
            <td>185cm</td>
        </tr>
        <tr>
            <td>张三</td>
            <td>男</td>
            <td>21</td>
            <td>185cm</td>
        </tr>
    </tbody>
</table>

<script>
    var trs = document.querySelector('tbody').querySelectorAll('tr');
    for (var i = 0; i < trs.length; i++) {
        //css的hover效果
        trs[i].onmouseover = function () {
            this.style.backgroundColor = 'pink';
        }
        trs[i].onmouseout = function () {
            this.style.backgroundColor = '';
        }
    }
</script>

</body>
</html>